﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3
{
    class indexer
    {
        string[] words = "The quick brown fox".Split();

        /// <summary>
        /// 索引器为访问类或者结构体中封装的列表或字典型数据元素提供了自然的访问接口
        /// </summary>
        /// <param name="wordNum"></param>
        /// <returns></returns>
        public string this [int wordNum] //indexer
        {
            get { return words[wordNum];}
            set { words[wordNum] = value;}
        }
        static void _Main(string[] args) {
            indexer s = new indexer();
            Console.WriteLine(s[3]);//fox
            s[3] = "kangaroo";
            Console.WriteLine(s[3]);//kangaroo
        }
    }
}
